function [C Z] = visualizeCurve(x,y,z,P,approxP,n,N,origIndex);

%% VISUALIZATION
% save De boor control points
figure();
Z = []; origSite = 1;
for i=1:n-1
   C(i,:) = [x((i-1)*N + 1) y((i-1)*N + 1) z((i-1)*N + 1)];
   
   % append orig site info
   if(~isempty(find(origIndex==i)))
       origSite = 1;
   else
       origSite = 0;
   end
   
   Z = [Z; [approxP(i,:) origSite]; [C(i,:) 0]];
end
Z = [Z; [approxP(n,:) 1]];

plot3(P(:,1),P(:,2),P(:,3),'ro:'); hold on;
plot3(approxP(:,1),approxP(:,2),approxP(:,3),'bo'); hold on;
plot3(C(:,1),C(:,2),C(:,3),'b*'); hold on;

time = [0:0.1:1]';
for i=1:n-1
    ind = 2*(i-1)+1;
    F = ((1-time).^2)*Z(ind,:) + 2*time.*(1-time)*Z(ind+1,:) + (time.^2)*Z(ind+2,:);
    plot3(F(:,1),F(:,2),F(:,3)); hold on;
end
grid on; %axis square;
